package com.onlyxiahui.extend.query.hibernate.syntax.util;

import java.util.Map;

import com.onlyxiahui.extend.query.hibernate.QueryWrapper;

/**
 * 
 * Description <br>
 * Date 2020-02-01 11:32:53<br>
 * 
 * @author XiaHui [onlovexiahui@qq.com]<br>
 * @since 1.0.0
 */
public class DeleteHqlUtil {

	public static String getDeleteHql(String beanName, QueryWrapper qw) {

		StringBuilder hql = new StringBuilder();
		Map<String, Object> map = (null == qw) ? null : qw.getParameterMap();
		if (map != null && !map.isEmpty()) {
			String alias = "data";
			String where = BaseHqlUtil.getWhereHqlByParameterValue(alias, qw, null);
			hql.append(" delete ");
			hql.append(beanName);
			hql.append(" ");
			hql.append(alias);
			hql.append(" ");
			hql.append(where);
		}
		return hql.toString();
	}
}
